package pl.dalkia.services.scanner.services.fetcher;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import pl.dalkia.services.scanner.services.matcher.DateConditionLogMatcher;
import pl.dalkia.services.scanner.services.matcher.Matchable;

public class Configuration {

	private Matchable datePatternMatcher;
	private List<Matchable> specificPatterns;
	
	public Configuration(Matchable datePatternMatcher) {
		super();
		this.datePatternMatcher = datePatternMatcher;
		this.specificPatterns = new ArrayList<Matchable>();
	}
	
	
	public void addSpecificPattern(Matchable specificPattern){
		this.specificPatterns.add(specificPattern);
	}


	public Matchable getDatePatternMatcher() {
		if (datePatternMatcher != null){
			return datePatternMatcher;
		}
		return new DateConditionLogMatcher("");
	}


	public List<Matchable> getSpecificPatterns() {
		return Collections.unmodifiableList(specificPatterns);
	}


	@Override
	public String toString() {
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.append("Date pattern:\n");
		stringBuilder.append(this.datePatternMatcher.getPattern());
		stringBuilder.append("\n\nSpecific pattern(s):\n");
		for(Matchable pattern : this.specificPatterns) {
			stringBuilder.append(pattern.getPattern());
			stringBuilder.append("\n");
		}
		return stringBuilder.toString();
	}
	
	
	
	
	
}
